<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">
<script>
    (function(){
        if(''){
            if (prompt('请输入文章密码') !== ''){
                alert('密码错误！');
                history.back();
            }
        }
    })();
</script>


  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT">










<meta name="description" content="向Kubernetes集群添加／移除NodeMinion Node操作前准备1234567891011121314151617#关闭防火墙systemctl stop firewalld#禁止防火墙开机启动systemctl disable firewalld#检查selinuxgetenforce Disabled#端口检查#关闭防火墙systemctl disable firewalldsys">
<meta property="og:type" content="article">
<meta property="og:title" content="K8S移除节点">
<meta property="og:url" content="http://nfvpn.com/2018/06/29/K8S移除节点/index.html">
<meta property="og:site_name" content="网探NFVPN">
<meta property="og:description" content="向Kubernetes集群添加／移除NodeMinion Node操作前准备1234567891011121314151617#关闭防火墙systemctl stop firewalld#禁止防火墙开机启动systemctl disable firewalld#检查selinuxgetenforce Disabled#端口检查#关闭防火墙systemctl disable firewalldsys">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-06-29T13:35:23.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="K8S移除节点">
<meta name="twitter:description" content="向Kubernetes集群添加／移除NodeMinion Node操作前准备1234567891011121314151617#关闭防火墙systemctl stop firewalld#禁止防火墙开机启动systemctl disable firewalld#检查selinuxgetenforce Disabled#端口检查#关闭防火墙systemctl disable firewalldsys">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://nfvpn.com/2018/06/29/K8S移除节点/">





  <title>K8S移除节点 | 网探NFVPN</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">网探NFVPN</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://nfvpn.com/2018/06/29/K8S移除节点/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Yokiy">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="网探NFVPN">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">K8S移除节点</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-06-29T21:21:21+08:00">
                2018-06-29
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="向Kubernetes集群添加／移除Node"><a href="#向Kubernetes集群添加／移除Node" class="headerlink" title="向Kubernetes集群添加／移除Node"></a>向Kubernetes集群添加／移除Node</h2><h3 id="Minion-Node操作前准备"><a href="#Minion-Node操作前准备" class="headerlink" title="Minion Node操作前准备"></a>Minion Node操作前准备</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">#关闭防火墙</span><br><span class="line">systemctl stop firewalld</span><br><span class="line">#禁止防火墙开机启动</span><br><span class="line"></span><br><span class="line">systemctl disable firewalld</span><br><span class="line"></span><br><span class="line">#检查selinux</span><br><span class="line"></span><br><span class="line">getenforce Disabled</span><br><span class="line"></span><br><span class="line">#端口检查#关闭防火墙</span><br><span class="line"></span><br><span class="line">systemctl disable firewalld</span><br><span class="line"></span><br><span class="line">systemctl stop firewalld</span><br><span class="line"></span><br><span class="line">systemctl status firewalld</span><br></pre></td></tr></table></figure>
<h3 id="Kubernetes集群中添加Node"><a href="#Kubernetes集群中添加Node" class="headerlink" title="Kubernetes集群中添加Node"></a>Kubernetes集群中添加Node</h3><p><strong><em>在kubeadm init初始化操作完成时，系统最后给出了将节点加入集群的命令：</em></strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">kubeadm join 10.0.0.39:6443 --token 4g0p8w.w5p29ukwvitim2ti</span><br><span class="line">--discovery-token-ca-cert-hash sha256:21d0adbfcb409dca97e655641573b2ee51c</span><br><span class="line">77a212f194e20a307cb459e5f77c8</span><br></pre></td></tr></table></figure></p>
<p><strong><em>说明：这条命令一定保存好，因为后期没法重现的！</em></strong><br><strong><em>在swarm1（Minion Node）上操作:</em></strong><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">kubeadm join 10.0.0.39:6443 --token 4g0p8w.w5p29ukwvitim2ti</span><br><span class="line">--discovery-token-ca-cert-hash sha256:21d0adbfcb409dca97e655641573b2ee51c</span><br><span class="line">77a212f194e20a307cb459e5f77c8</span><br></pre></td></tr></table></figure></p>
<p><strong><em>在swarm2（Master）上操作：</em></strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">kubectl get nodes</span><br><span class="line">NAME STATUS ROLES AGE VERSION</span><br><span class="line">swarm1 Ready &lt;none&gt; 3h v1.10.0</span><br><span class="line">swarm2 Ready master 3h v1.10.0</span><br></pre></td></tr></table></figure>
<p><strong><em>swarm1加入集群很是顺利！</em></strong></p>
<h3 id="Kubernetes集群中移除Node"><a href="#Kubernetes集群中移除Node" class="headerlink" title="Kubernetes集群中移除Node"></a>Kubernetes集群中移除Node</h3><p><strong><em>在master节点上执行：</em></strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">kubectl drain swarm1 --delete-local-data --force --ignore-daemonsets</span><br><span class="line">kubectl delete node swarm1</span><br></pre></td></tr></table></figure>
<p><strong><em>在node2上执行：</em></strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">kubeadm reset</span><br></pre></td></tr></table></figure>
<h3 id="添加Node出现的问题"><a href="#添加Node出现的问题" class="headerlink" title="添加Node出现的问题"></a>添加Node出现的问题</h3><p><strong><em>Minion Node一直处于notReady状态，如：</em></strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">kubectl get nodes</span><br><span class="line">NAME      STATUS     ROLES     AGE       VERSION</span><br><span class="line">swarm1    NotReady   &lt;none&gt;    3h        v1.10.0</span><br><span class="line">swarm2    Ready      master    3h        v1.10.0</span><br></pre></td></tr></table></figure>
<p><strong><em>原因: </em></strong></p>
<ol>
<li><p>启动kubelet的时候，会pull以下两个镜像(gcr.io/**)，因为天朝网络一般翻不了墙，不能成功pull，所以要自己找到这两个docker镜像。点击images自行下载使用！</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">k8s.gcr.io/kube-proxy-amd64   v1.10.0             6e6237849607        3 weeks ago         97.1 MB</span><br><span class="line">k8s.gcr.io/pause-amd64        3.1                 da86e6ba6ca1        4 months ago        742 kB</span><br></pre></td></tr></table></figure>
</li>
<li><p>使用Kubeadm工具搭建的Kubernetes集群，已经默认集成了安全策略，所以要将Master Node节点/etc/kubernetes/pki下的所有文件复制到Minion Node相同目录下一份。所以在Master Node上执行：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">scp /etc/kubernetes/pki/* root@&#123;minion-ip&#125;:/etc/kubernetes/pki</span><br></pre></td></tr></table></figure></li>
</ol>

      
    </div>
    
    
    
    <div>
          
            

          
    </div>
    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/06/11/Yokiy开源运维平台/" rel="next" title="Yokiy 运维自动化平台项目">
                <i class="fa fa-chevron-left"></i> Yokiy 运维自动化平台项目
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/08/07/Python-SDK-阿里云容器镜像仓库/" rel="prev" title="Python SDK 阿里云容器镜像仓库">
                Python SDK 阿里云容器镜像仓库 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
      <div>
        
          <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>

        
      </div>
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Yokiy</p>
              <p class="site-description motion-element" itemprop="description">记录一些工作经验</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">19</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">2</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#向Kubernetes集群添加／移除Node"><span class="nav-number">1.</span> <span class="nav-text">向Kubernetes集群添加／移除Node</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Minion-Node操作前准备"><span class="nav-number">1.1.</span> <span class="nav-text">Minion Node操作前准备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Kubernetes集群中添加Node"><span class="nav-number">1.2.</span> <span class="nav-text">Kubernetes集群中添加Node</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Kubernetes集群中移除Node"><span class="nav-number">1.3.</span> <span class="nav-text">Kubernetes集群中移除Node</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#添加Node出现的问题"><span class="nav-number">1.4.</span> <span class="nav-text">添加Node出现的问题</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Yokiy</span>

  
</div>
<div class="powered-by">
<i class="fa fa-user-md"></i><span id="busuanzi_container_site_pv">
  本站访客数:<span id="busuanzi_value_site_uv"></span>
</span>
</div>

  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>



<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共7.7k字</span>
  <a href="http://www.miitbeian.gov.cn">备案号：湘ICP备16017335号</a>
</div>

        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
